

<hr class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input type="text" name="search_data"  placeholder="名称" autocomplete="off" value="{:input('search_data')}"  class="layui-input">
            <button class="layui-btn"  id="search"  url="{:url('user_recharge_list')}"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
        <!--<span style="color:red;">当前ETH转账手续费：</span>-->
    </div>
    <xblock>
        <button class="layui-btn ladda-button" onclick="transferAll()">批量转入汇总地址</button>
        <button type="button"  class="layui-btn ladda-button" onclick="renewal_balance()">
            批量更新余额
        </button>
        <button class="layui-btn ladda-button" onclick="mineAll()">批量转入矿工费</button>
        <!-- <button type="button"  class="layui-btn ladda-button" onclick="summary_balance()">
            批量转入汇总地址
        </button> -->
        <ob_link><a  href="{:url('user_recharge_list',['is_money'=>1])}" style="color: white">   <button class="layui-btn" > 有余额的会员</button></a></ob_link>
        <span class="x-right" style="line-height:40px;margin-right:10px;">当前会员ETH余额：{$total.eth} </span>
        <span class="x-right" style="line-height:40px; margin-right:10px;">当前会员USDT余额：{$total.usdt}</span>
        <span class="x-right" style="line-height:40px; margin-right:10px;">转入汇总数量：{$total.summary}</span>
    </xblock>

    <div class="progress_bar" style="display:none;">
        <hr/>
        <div class="layui-progress layui-progress-big" lay-filter="demo" lay-showPercent="true">
            <div class="layui-progress-bar" lay-percent="20%"></div>
        </div>
    </div>


        <hr/>
    <table class="layui-table x-admin">
        <thead>
        <tr>

            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>

            <th>序号</th>
            <th>会员信息</th>
            <th>链上钱包地址</th>
            <th>链上余额</th>
            <th>操作</th>
        </thead>
        {notempty name='list'}
        <tbody>
        {volist name='list' id='vo' key="k"}
        <tr>

            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$vo.userinfo["id"]}'><i class="layui-icon">&#xe605;</i></div>
            </td>

            <td>{$vo.id+1}</td>
            <td>

                <div> <label>用户头像:</label><span><img height="32px" src="{$vo.userinfo['head_pic']}"></span></div>
                <div> <label>UID:</label><span>{$vo.userinfo['id']}</span></div>
                <div> <label>会员账号:</label><span>{$vo.userinfo['username']}</span></div>
                <div> <label>手机号:</label><span>{$vo.userinfo['mobile']}</span></div>
                <div> <label>是否公司账户:</label><span>{if condition="$vo.userinfo['is_company'] eq 1"}是{else/}否{/if}</span></div>
                <div> <label>是否赌王:</label><span>{if condition="$vo.userinfo['is_king'] eq 1"}是{else/}否{/if}</span></div>
                <div> <label>是否商家:</label><span>{if condition="$vo.userinfo['is_shop'] eq 1"}是{else/}否{/if}</span></div>
            </td>
            <td>
                <!-- {notempty name="vo.address['ccie']['blockchain_address2']"}  <div> <label>CCIE:</label><span>{$vo.address['ccie']['blockchain_address2']}</span></div>{/notempty} -->
                {notempty name="vo.address['eth']['blockchain_address2']"}     <div> <label>ETH:</label><span>{$vo.address['eth']['blockchain_address2']}</span></div>{/notempty}
                {notempty name="vo.address['btc']['blockchain_address2']"}     <div> <label>BTC:</label><span>{$vo.address['btc']['blockchain_address2']}</span></div>{/notempty}
                {notempty name="vo.address['usdt']['blockchain_address2']"}  <div> <label>USDT:</label><span>{$vo.address['usdt']['blockchain_address2']}</span></div>{/notempty}
            </td>

            <td>
                <!-- {notempty name="vo.address['ccie']['blockchain_address2']"}     <div> <label>CCIE余额:</label><span>{$vo.address['ccie']['number']}</span></div>{/notempty} -->
                {notempty name="vo.address['eth']['blockchain_address2']"}     <div> <label>ETH余额:</label><span>{$vo.address['eth']['number']}</span></div>{/notempty}
                {notempty name="vo.address['btc']['blockchain_address2']"}  <div> <label>BTC余额:</label><span>{$vo.address['btc']['number']}</span></div>{/notempty}
                {notempty name="vo.address['usdt']['blockchain_address2']"} <div> <label>USDT余额:</label><span>{$vo.address['usdt']['number']}</span></div>{/notempty}
            </td>

            <td class="td-manage">
                <!--<a onclick="member_stop(this,'10001')" href="javascript:;"  title="启用">-->
                <!--<i class="layui-icon">&#xe601;</i>-->
                <!--</a>-->
                <div> <a title="更新余额" class="ajax-get" href="{:url('update_number', array('user_id' => $vo['user_id']))}" >
                    更新余额
                </a></div>
                <div> <a title="转入汇总地址" class="ajax-get" href="{:url('transfer_to_summary', array('user_id' => $vo['user_id']))}" >
                    转入汇总地址
                </a></div>

                <div> <a title="批准"  href="javascript:reply({$vo['user_id']},4);" >
                    转入矿工费
                </a></div>


            </td>
        </tr>
        {/volist}
        {else/}
        <tbody><tr class="odd"><td colspan="12" class="text-center" valign="top">{:config('empty_list_describe')}</td></tr></tbody>
        {/notempty}

        </tbody>
    </table>

    <div class="page">
        {notempty name='users'}   {$users->render()}{/notempty}
    </div>

</div>
<script>
    layui.use('form', function(){
        form = layui.form;

    });
    function delAll (argument) {

        var data = tableCheck.getData();


        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            //监听提交
            var url="{:url('setStatus')}";
            $.post(url,{ids:data,status:-1},function (d) {
                if(d.code==1){
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                    layer.msg('删除成功', {icon: 1});

                }else{
                    layer.msg(d.msg);

                }
            },'json');



        });
    }
    function reply(id ,state) {
        layer.open({
            type: 2 //此处以iframe举例
            ,title: '转入矿工费'
            ,area: ['60%', '40%']
            ,shade: 0
            ,maxmin: true
            ,content: "/admin.php/wallet/mine_transfer?user_id="+id
            ,btn: [] //只是为了演示
        });
    }
    function transfer(obj,from,symbol){
    	console.log(from);
    	console.log(symbol);
    	layer.prompt({
		  formType: 2,
		  value: '',
		  title: '请输入收款地址',
		}, function(to, index, elem){
			if(to == ""){
		  		layer.msg("请输入转出地址");
		  		return false;
			}
			layer.prompt({
			  formType: 2,
			  value: '',
			  title: '请输入数量',
			}, function(number, index2, elem){
				if(number == ""){
			  		layer.msg("请输入数量");
			  		return false;
				}
				var url="{:url('transfer')}";
	            $.post(url,{"from":from,"to":to,"symbol":symbol,"number":number},function (d) {
	                if(d.code==1){
	                    layer.msg('转账成功，HASH：'+d.msg, {icon: 1});
	                }else{
	                    layer.msg(d.msg);
	
	                }
	            },'json');
				layer.close(index2);
			});
		  layer.close(index);
		});
    }
    
    function transfer_qrcode(address){
    	layer.alert('<img src="/api.php/common/qrcode?access_token=5b7f60aca7e7f6f8c680b1b219ad3ec6&address='+address+'">')
    }

    function transferAll (argument) {

        var data = tableCheck.getData();


        layer.confirm('确认要批量转入汇总地址吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            //监听提交
            var url="{:url('transferall')}";
            $.post(url,{ids:data},function (d) {
                if(d.code==1){
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                    layer.msg('汇总成功', {icon: 1});

                }else{
                    layer.msg(d.msg);

                }
            },'json');



        });
    }

    function mineAll(argument){
        var data = tableCheck.getData();
        layer.open({
            type: 2 //此处以iframe举例
            ,title: '转入矿工费'
            ,area: ['60%', '40%']
            ,shade: 0
            ,maxmin: true
            ,content: "/admin.php/wallet/mine_all?ids="+data
            ,btn: [] //只是为了演示
        });
    }


    function  renewal_balance() {
        var data = tableCheck.getData();
        console.log(data);
        // return;
        var url="{:url('update_number')}";
        // console.log(url);
        var len=data.length;
        if(len>0){

            $('.ladda-button').attr('disabled',true);
            $('.progress_bar').show();
            element.progress('demo', '0%');
            r1(data,len,0,url,0)
        }else{
            layer.msg('请选择要操作的用户');
        }
    }


    function  summary_balance() {
        var data = tableCheck.getData();
        // console.log(data);
        // return;
        var url="{:url('transfer_to_summary')}";
        var len=data.length;
        if(len>0){

            $('.ladda-button').attr('disabled',true);
            $('.progress_bar').show();
            element.progress('demo', '0%');
            r1(data,len,0,url,0)
        }else{
            layer.msg('请选择要操作的用户');
        }
    }

    function r1(data,num,count,url,total) {
        console.log(data[count])
        $.post(url,{user_id:data[count],is_pi:1},function (d) {

            if(d.code==1){

                count++;
                var pro =count/num*100;
                pro = pro.toFixed(2);
                element.progress('demo', pro+'%');
                if(count<num){
                    setTimeout( r1(data,num,count,url,total),1000);

                }else{
                    var ur="{:url('update_number')}"
                    if(url==ur){
                        total+=d.data;
                        layer.msg(d.msg+',当前数量：'+total);
                    }else{
                        layer.msg(d.msg);
                    }

                    $('.ladda-button').attr('disabled',false);

                }
            }else{
                layer.msg(d.msg);
                $('.ladda-button').attr('disabled',false);

            }
        });
    }




</script>

</body>

</html>